import request from '@/utils/request'
import { requestWrapper } from '@/utils/mock'

// 获取缓存信息
export function getCacheInfo() {
  return requestWrapper(
    // 真实API请求
    () => request({
      url: '/monitor/cache',
      method: 'get'
    }),
    // 模拟数据
    {
      commandStats: [
        {
          command: "get",
          calls: 1000,
          usec_per_call: 10
        },
        {
          command: "set",
          calls: 500,
          usec_per_call: 20
        },
        {
          command: "del",
          calls: 100,
          usec_per_call: 5
        },
        {
          command: "keys",
          calls: 50,
          usec_per_call: 30
        },
        {
          command: "hset",
          calls: 200,
          usec_per_call: 15
        },
        {
          command: "hget",
          calls: 300,
          usec_per_call: 8
        }
      ],
      info: {
        redis_version: "6.2.6",
        uptime_in_days: "15",
        connected_clients: "8",
        used_memory: "10485760",
        used_memory_human: "10.00M",
        used_memory_peak: "12582912",
        used_memory_peak_human: "12.00M",
        mem_fragmentation_ratio: "1.08",
        total_connections_received: "1200",
        total_commands_processed: "8500"
      },
      dbSize: 235
    }
  )
}

// 清理缓存
export function clearCache() {
  return requestWrapper(
    // 真实API请求
    () => request({
      url: '/monitor/cache/clear',
      method: 'delete'
    }),
    // 模拟数据
    {
      success: true
    }
  )
} 